package cn.tradewin.advisor.pages.passets.master;

import java.util.List;

import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;
import org.slf4j.Logger;

import cn.tradewin.advisor.persist.model.ChkLang;
import cn.tradewin.advisor.persist.services.PassetsMasterService;

public class ChkLangMaster {
	
	@Inject
	private BeanModelSource beanModelSource;
	
	@Property
	private BeanModel<ChkLang> beanModel;
	
	@Property
	private List<ChkLang> langs;
	
	@Property
	private ChkLang lang;
	
	@Property
	private String desc;
	
	@Inject
	private Messages messages;
	
	@Inject
	private Logger log;
	
	@Inject
	private PassetsMasterService passetsMasterService;
	
	@Property
	private ChkLang category;
	
	void setupRender() {
		beanModel = beanModelSource.createDisplayModel(ChkLang.class, messages);
		beanModel.add("action", null);
		beanModel.include("desc", "action");
		beanModel.get("desc").sortable(false);
		langs = passetsMasterService.getChkLangs();
	}
	
	@Log
	void onSubmit() {
		ChkLang in = new ChkLang();
		in.setDesc(desc);
		passetsMasterService.addChkLang(in);
	}
	
	void onDelete(Integer code) {
		passetsMasterService.delChkLang(code);
	}
}
